package com.itheima.datastructure.binarysearchtree.binarytree;

//对称二叉树
public class E04Leetcode101 {
    public boolean isSymmetric(TreeNode root){
        return check(root.left,root.right);
    }

    private boolean check(TreeNode left,TreeNode right){
        if(left==null && right==null){
            return true;
        }
        //left不能同时为null
        if(right==null || left==null){
            return false;
        }
        if(left.val!=right.val){
            return false;
        }
        //递归操作
        return check(left.left,right.right) && check(left.right,right.left);
    }
}
